<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>冒泡排序</title>
</head>

<body>

</body>
<script>
    function sort(arr) {
        for (let i = arr.length; i > 0; i--) {
            for (let j = 0; j < i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    let temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        return arr;
    }
    let arr1 = [0, 3, 2, 1, 4, 15, 6, 7, 3, 1, 4, 34, 2];
    console.log(sort(arr1));
</script>

</html>